Skip to content

Add innerHTML and outerHTML getters for focus navigation fixtures - #113

Open
cowboyd wants to merge 1 commit into
wpt-document-lifecyclefrom
dom-html-serialization
Open

cowboyd wants to merge 1 commit into
wpt-document-lifecyclefrom
dom-html-serialization

Conversation

@cowboyd

@cowboyd cowboyd commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

This PR is part of of the "Input Stack" which adds the following capabilities to the Dom

  • Focus management: focus(), blur(), activeElement, focus events, and cleanup when focused nodes are removed.
  • Focus navigation: Tab/Shift+Tab, tabindex ordering, wrapping, and disabled/inert filtering.
  • Focus styling: :focus, :focus-within, and :focus-visible under our keyboard-only policy.
  • Input editing: typing, replacing selections, Backspace/Delete, and cancelable beforeinput followed by input.
  • Caret movement: Left/Right across grapheme boundaries; Up/Down to the beginning/end of single-line inputs.
  • Shift-selection: extend, shrink, and reverse a selection while preserving its anchor. Readonly inputs allow movement and selection.
  • Input state APIs: value, selection endpoints/direction, setSelectionRange(), and setRangeText().

What does this PR do?

Some WPT test cases use the outerHTML property to generate the test names. Since we'll need innerHTML and outerHTML eventually, this adds readonly support for them.

Adds Element.innerHTML and Element.outerHTML serialization by using parse5 which is already a development dependency, but moves to be a runtime dependency.

Focus and input tests this supports

  1. Tab and Shift+Tab focus movement around tables: html/interaction/focus/tab-table-caption.html uses outerHTML to build its test names. With the lifecycle and keyboard rungs, all 12 cases across the two caption-side variants now reach their focus-navigation assertions.
  2. Inert selection across HTML, SVG, and MathML: inert/inert-on-non-html.html uses innerHTML.trim() to name 27 cases checking which content remains selectable when inert is applied to HTML or non-HTML elements and their ancestors.
  3. Input-event target ranges during word deletion: the getTargetRanges() returns correct range and cleared after dispatch. case in input-events/input-events-get-target-ranges.html reads innerHTML before and after deletion to check the DOM contents alongside the beforeinput/input target ranges.
  4. Deletion beside noneditable content: editing/other/insert-br-tag-on-text-node-removal-with-non-editable-elements.html uses innerHTML in three cases checking the resulting structure and placeholder <br> insertion after deleting text before, between, or after noneditable children.

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • All tests pass (pnpm test)
  • Files are formatted (pnpm format)
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code

@pkg-pr-new

pkg-pr-new Bot commented Nov 30, 2026

Copy link
Copy Markdown

commit: 85257f6

@cowboyd
cowboyd added this pull request to stack #114 November 30, 2026 15:21
@cowboyd
cowboyd marked this pull request as ready for review November 30, 2026 15:50
@cowboyd
cowboyd force-pushed the dom-html-serialization branch from 85257f6 to b111e1c Compare December 1, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant